//
// Book:      OpenGL(R) ES 2.0 Programming Guide
// Authors:   Aaftab Munshi, Dan Ginsburg, Dave Shreiner
// ISBN-10:   0321502795
// ISBN-13:   9780321502797
// Publisher: Addison-Wesley Professional
// URLs:      http://safari.informit.com/9780321563835
//            http://www.opengles-book.com
//

//
/// \file ESUtil.h
/// \brief A utility library for OpenGL ES.  This library provides a
///        basic common framework for the example applications in the
///        OpenGL ES 2.0 Programming Guide.
//
#ifndef ESUTIL_H
#define ESUTIL_H

#include "Includes.h"

#define ESUTIL_API
#define ESCALLBACK

struct ESMatrix
{
    GLfloat   m[4][4];
	GLfloat* toArray() { return &m[0][0]; }

	void Load(GLuint location)
	{
		glUniformMatrix4fv(location, 1, GL_FALSE, toArray());
	}
};

void ESUTIL_API esScale(ESMatrix *result, GLfloat sx, GLfloat sy, GLfloat sz);
void ESUTIL_API esTranslate(ESMatrix *result, GLfloat tx, GLfloat ty, GLfloat tz);
void ESUTIL_API esRotate(ESMatrix *result, GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
void ESUTIL_API esLookAt(ESMatrix *result, float eyex, float eyey, float eyez, float centerx, float centery, float centerz);
void ESUTIL_API esFrustum(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ);
void ESUTIL_API esPerspective(ESMatrix *result, float fovy, float aspect, float nearZ, float farZ);
void ESUTIL_API esOrtho(ESMatrix *result, float left, float right, float bottom, float top, float nearZ, float farZ);
void ESUTIL_API esMatrixMultiply(ESMatrix *result, ESMatrix *srcA, ESMatrix *srcB);
void ESUTIL_API esVectorMultiply(float *result, ESMatrix *srcA, float *srcB);
void ESUTIL_API esMatrixLoadIdentity(ESMatrix *result);
void ESUTIL_API esMatrixTranspose(ESMatrix *result);

#endif // ESUTIL_H
